this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(t,e,n,i,a,r){"use strict";var l,o;function s(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function u(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){babelHelpers.defineProperty(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var c=Symbol("instances");var g=function(t){babelHelpers.inherits(e,t);function e(t){var i;babelHelpers.classCallCheck(this,e);i=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(e).call(this,u(u({},t),{},{textOnly:true})));i.setEventNamespace("BX.Landing.UI.Field.VariablesField");i.onButtonClick=i.onButtonClick.bind(babelHelpers.assertThisInitialized(i));i.onTopDocumentClick=i.onTopDocumentClick.bind(babelHelpers.assertThisInitialized(i));n.Event.bind(window.top.document,"click",i.onTopDocumentClick);n.Dom.append(i.getLayout(),i.layout);e[c].push(babelHelpers.assertThisInitialized(i));return i}babelHelpers.createClass(e,[{key:"onTopDocumentClick",value:function t(){}},{key:"onInputClick",value:function t(e){this.lastRange=this.input.ownerDocument.createRange(this.input.innerText.length,this.input.innerText.length);this.lastRange=this.input.ownerDocument.getSelection().getRangeAt(0)}},{key:"getLayout",value:function t(){var e=this;return this.cache.remember("layout",(function(){return n.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-field landing-ui-field-variables">\n\t\t\t\t\t<div class="landing-ui-field-variables-left">','</div>\n\t\t\t\t\t<div class="landing-ui-field-variables-right">',"</div>\n\t\t\t\t</div>\n\t\t\t"])),e.input,e.getButton())}))}},{key:"getButton",value:function t(){var e=this;return this.cache.remember("button",(function(){return n.Tag.render(o||(o=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div \n\t\t\t\t\tclass="landing-ui-field-variables-button" \n\t\t\t\t\tonclick="','"\n\t\t\t\t></div>\n\t\t\t'])),e.onButtonClick)}))}},{key:"getMenu",value:function t(){var i=this;return this.cache.remember("menu",(function(){var t=r.PageObject.getRootWindow();var a=new t.BX.Main.Menu({bindElement:i.getButton(),targetContainer:i.getLayout(),autoHide:true,maxHeight:250,items:i.options.variables.map((function(t){if(t.delimiter){return{delimiter:true}}return{text:t.name,onclick:function e(){i.onVariableClick(t);a.close()}}})),events:{onPopupShow:function t(){e[c].forEach((function(t){if(t!==i){t.getMenu().close()}}));setTimeout((function(){n.Dom.style(a.getMenuContainer(),{left:"auto",right:"0px",top:"30px"})}))}}});return a}))}},{key:"onInputInput",value:function t(){var n=this.getLayout().ownerDocument;this.lastRange=n.getSelection().getRangeAt(0);babelHelpers.get(babelHelpers.getPrototypeOf(e.prototype),"onInputInput",this).call(this)}},{key:"onVariableClick",value:function t(e){this.enableEdit();this.input.focus();var n=this.getLayout().ownerDocument;if(this.lastRange){n.getSelection().removeAllRanges();n.getSelection().addRange(this.lastRange)}n.execCommand("insertText",null," ".concat(e.value," "))}},{key:"onButtonClick",value:function t(e){e.preventDefault();e.stopPropagation();if(!this.lastRange&&this.input.innerText.length){var n=this.input.ownerDocument;n.getSelection().collapse(this.input.childNodes[0],this.input.innerText.length);this.lastRange=n.getSelection().getRangeAt(0)}var i=this.getMenu();if(i.getPopupWindow().isShown()){this.getMenu().close()}else{this.getMenu().show()}}},{key:"getValue",value:function t(){return this.input.innerText}}]);return e}(e.TextField);babelHelpers.defineProperty(g,c,[]);t.VariablesField=g})(this.BX.Landing.UI.Field=this.BX.Landing.UI.Field||{},BX.Landing.UI.Field,BX,BX.Landing.UI.Button,BX.Main,BX.Landing);
//# sourceMappingURL=variablesfield.bundle.map.js